﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using socialnexus.classes.models;
using socialnexus.classes.pages;

namespace socialnexus.admin
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] != null)
            {
                Response.Redirect("~/admin/Users/");
            }
        }

        protected void adminLogin_Authenticate(object sender, AuthenticateEventArgs e)
        {
            Login login = (Login)sender;
            Session["admin"] = AdminUser.Authenticate(login.UserName, login.Password);
            if (Session["admin"] == null)
            {
                login.FailureText = "Login failed. Please retry.";
            }
            else
            {
                e.Authenticated = true;
                Response.Redirect("~/admin/Users/");
            }
        }
    }
}
